//
//  ShipperCompleteViewController.m
//  Commerce
//
//  Created by xiaofeifei on 15/2/9.
//  Copyright (c) 2015年 fei. All rights reserved.
//

#import "ShipperCompleteViewController.h"

@interface ShipperCompleteViewController ()

@end

@implementation ShipperCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}


#pragma mark -请求接口
- (void)getCompleteUserInfo{
    [SVProgressHUD showWithStatus:@"加载中" maskType:SVProgressHUDMaskTypeBlack];
    NSString *uid = [[GlobalData sharedGlobalData] userinfoDic][@"UserID"];
    NSMutableDictionary *parameters = [GlobalData paramterDic];
    [parameters addEntriesFromDictionary:@{@"userid":uid,
                                           @"company_name":_companyNameField.text,
                                           @"true_name":_nameTextField.text,
                                           @"address":_addressTextField.text,
                                           @"mobile":_phoneTextField.text,
                                           }];
    [[BaseNetwork alloc] initWithMethodUrl:[NSString stringWithFormat:@"%@user/userinfo",URL_ROOT]
                                    params:parameters
                               requestMode:DGHTTPMethodPOST
                               loadingShow:YES
                              didFinshLoad:^(id result) {
                                  id responseObject = result;
                                  [SVProgressHUD dismiss];
                                  if (responseObject[@"result"]) {
                                      [SVProgressHUD showSuccessWithStatus:@"提交成功，等待管理员审核"];
                                      [self backBtnAct:nil];
                                  }else{
                                      [SVProgressHUD showInfoWithStatus:@"提交失败"];
                                  }
                                  
                                  
                              }];
}

- (IBAction)saveUserInfo:(id)sender{
    if ([[GlobalData sharedGlobalData] userinfoDic] == nil) {
        [SVProgressHUD showInfoWithStatus:@"请先登录"];
    }
    else if (_companyNameField.text.length == 0) {
        [SVProgressHUD showInfoWithStatus:@"请填写公司名"];
    }
    else if (_nameTextField.text.length == 0){
        [SVProgressHUD showInfoWithStatus:@"请填写姓名"];
    }
    else if (_phoneTextField.text.length == 0){
        [SVProgressHUD showInfoWithStatus:@"请填写电话号码"];
    }
    else if (_addressTextField.text.length == 0){
        [SVProgressHUD showInfoWithStatus:@"请填写联系地址"];
    }
    else{
        [self getCompleteUserInfo];
    }
}

- (IBAction)clearUserInfo:(id)sender{
    _companyNameField.text = nil;
    _nameTextField.text = nil;
    _phoneTextField.text = nil;
    _addressTextField.text = nil;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
